import time
from time import sleep
from selenium import webdriver

# 打开浏览器-创建浏览器对象
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

# 打开浏览器
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path='chromedriver.exe')

# 输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")
# driver = webdriver.Chrome()

# 放大浏览器
driver.maximize_window()

# 输入用户名：admin1，暂停2秒，删除1
username = driver.find_element_by_css_selector("#userA")
username.send_keys("admin1")

# 暂停2秒
time.sleep(2)

# 删除1
username.send_keys(Keys.BACK_SPACE)

# 全选用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL, 'a')
time.sleep(2)

# 复制用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL, 'c')
time.sleep(2)

# 粘贴到密码框
# 定位到密码框，执行ctrl+v
password = driver.find_element_by_css_selector("#passwordA")
password.send_keys(Keys.CONTROL, 'v')
time.sleep(2)

# 关闭浏览器
driver.quit()